package Demo.继承多态;

public class Boy {
    String name;

    public void play(Pet p){
        p.happy();
    }

    /*public void play(Pet p){
        if(p instanceof Cat){
            Cat c = (Cat)p;
            c.catHappy();
        }
        if(p instanceof Dog){
            Dog d = (Dog)p;
            d.dogHappy();
        }
        else{
            p.petHappy();
        }
    }*/

    /*public void play(Dog dog){
        dog.dogHappy();
    }

    public void play(Cat cat){
        cat.catHappy();
    }*/
}